<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增广告位管理')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-adplace-add">
            <div class="form-group">    
                <input type="hidden" name="platform" th:value="${platform}"/>
                <label class="col-sm-3 control-label">应用ID：</label>
                <div class="col-sm-8">
                    <select name="appId" class="form-control m-b" th:with="type=${@dict.getType('kkad_app_id')}" style="pointer-events: none;">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="*{appId} == ${dict.dictValue}" ></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">类型：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control m-b" th:with="type=${@dict.getType('kkad_ad_type')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">宽：</label>
                <div class="col-sm-2">
                    <input name="width" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">高：</label>
                <div class="col-sm-2">
                    <input name="height" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">说明：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">启用：</label>
                <div class="col-sm-8">
                    <label class="toggle-switch switch-solid">
                     <input type="checkbox" id="status" >
                     <span></span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开启第三方广告：</label>
                <div class="col-sm-8">
                    <label class="toggle-switch switch-solid">
                     <input type="checkbox" id="openThird" >
                     <span></span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">第三方类型：</label>
                <div class="col-sm-8">
                    <select name="thirdType" class="form-control m-b" th:with="type=${@dict.getType('kkad_third_type')}">
                        <option value=""></option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "kkad/adplace"
        $("#form-adplace-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
            	var data = $('#form-adplace-add').serializeArray()
            	var status = $("input[id='status']").is(':checked') == true ? 1 : 0;
            	data.push({"name": "status", "value": status});
            	var openThird = $("input[id='openThird']").is(':checked') == true ? 1 : 0;
            	data.push({"name": "openThird", "value": openThird});
                $.operate.save(prefix + "/add", data);
            }
        }
        
        $("input[name='createdTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>